package com.hyw.supply.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public enum OrderStatusEnum {

    PENDING_PAYMENT(0, "待付款"),
    shipped_STOCKED(1, "待发货-待备货"),
    SHIPPED_OUTBOUND_FAIL(2, "待发货-出库失败"),
    SHIPPED_OUTBOUND_ING(3, "待发货-出库中"),
    SHIPPED_OUTBOUND_PART(4, "待发货-部分出库!"),
    PENDING_REVIEW(5, "退单待审核"),
    RECEIVED(6, "待收货"),
    COMPLETED(7, "已完成"),
    CHARGED(8, "已退单"),
    CANCELED(9, "已取消");

    OrderStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private Integer code;

    private String msg;

    public static String getMsgByCode(int code) {
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (status.getCode() == code) {
                return status.getMsg();
            }
        }
        return null;
    }

    public static Integer getCodeByMsg(String msg) {
        if (StringUtils.isBlank(msg)) {
            return null;
        }
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (status.getMsg().equals(msg)) {
                return status.getCode();
            }
        }
        return null;
    }


}
